package cn.zsssgjcx.hjsg.activity;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import cn.zsssgjcx.hjsg.R;
import cn.zsssgjcx.hjsg.adapter.LocationAdapter;
import cn.zsssgjcx.hjsg.adapter.StationAdapter;
import cn.zsssgjcx.hjsg.model.LocationInfo;
import cn.zsssgjcx.hjsg.model.StationInfo;
import cn.zsssgjcx.hjsg.utils.StatusBarUtils;

public class SearchActivity extends AppCompatActivity {

    private ImageView iv_left;
    private ImageView iv_clear;
    private EditText et_keyword;
    private ListView lv_location;

    private ListView lv_station;

    private List<LocationInfo> locationInfoList = new ArrayList<>();
    private LocationAdapter locationAdapter;

    private List<StationInfo> stationInfoList = new ArrayList<>();
    private StationAdapter stationAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(ContextCompat.getColor(this, R.color.white));

            //状态栏设置为白亮，就是图标为白色
            StatusBarUtils.setLightStatusBar(this, true, false);
        }

        iv_left = findViewById(R.id.iv_left);
        iv_clear = findViewById(R.id.iv_clear);
        et_keyword = findViewById(R.id.et_keyword);

        lv_location = findViewById(R.id.lv_location);

        lv_station = findViewById(R.id.lv_station);

        locationInfoList.add(new LocationInfo());
        locationInfoList.add(new LocationInfo());

        locationAdapter = new LocationAdapter(SearchActivity.this,locationInfoList);

        lv_location.setAdapter(locationAdapter);

        stationInfoList.add(new StationInfo());
        stationInfoList.add(new StationInfo());

        stationAdapter = new StationAdapter(SearchActivity.this, stationInfoList);

        lv_station.setAdapter(stationAdapter);

        lv_location.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent = new Intent(SearchActivity.this,RouteActivity.class);
                startActivity(intent);
            }
        });

        iv_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        iv_clear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                et_keyword.setText("");
            }
        });
    }
}